import requests


class IhrmEmpApi(object):

    @classmethod
    def add_emp(cls, req_headers, req_data):
        return requests.post(url="http://ihrm-test.itheima.net/api/sys/user",
                             headers=req_headers, json=req_data)

    @classmethod
    def get_emp(cls, req_id, req_headers):
        return requests.get(url="http://ihrm-test.itheima.net/api/sys/user/" + req_id,
                            headers=req_headers)

    @classmethod
    def put_emp(cls, req_id, req_headers, req_data):
        return requests.put(url="http://ihrm-test.itheima.net/api/sys/user/" + req_id,
                            headers=req_headers, json=req_data)

    @classmethod
    def delete_emp(cls, req_id, req_headers):
        return requests.delete(url="http://ihrm-test.itheima.net/api/sys/user/" + req_id,
                               headers=req_headers)


if __name__ == '__main__':
    req_headers = {"Authorization": "27c1e90a-c94b-428b-a010-3a84f7d2c4dc"}
    req_data = {"username": "user87155430",
                "mobile": "13941884780",
                "workNumber": "9527190aa"}
    # resp = IhrmEmpApi.add_emp(req_headers,req_data)
    # print("添加员工成功:",resp.json())

    req_id = "1516358115057057792"
    resp = IhrmEmpApi.get_emp(req_id,req_headers)
    print("查询成功：",resp.json())
